package com.hfkh.keyun.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hfkh.keyun.common.ApiResult;
import com.hfkh.keyun.entity.Carousel;
import com.hfkh.keyun.entity.Course;
import com.hfkh.keyun.entity.Evaluate;
import com.hfkh.keyun.exception.BusinessException;
import com.hfkh.keyun.mapper.EvaluateMapper;
import com.hfkh.keyun.service.EvaluateService;
import com.hfkh.keyun.util.PageDTO;
import com.hfkh.keyun.vo.EvaluateVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.util.pattern.PathPattern;

import javax.annotation.Resource;
import javax.print.DocFlavor;
import java.io.IOException;
@Slf4j
@Service
public class EvaluateServiceImpl extends ServiceImpl<EvaluateMapper, Evaluate> implements EvaluateService {
    @Resource
    private EvaluateMapper evaluateMapper;
    @Override
    public ApiResult addEvaluate(EvaluateVO evaluateVO) throws IOException, BusinessException {
        return ApiResult.success(evaluateVO);
    }
    @Override
    public ApiResult queryPage(Integer id, Integer page, Integer size) {
        Page<Evaluate> itemPage = new Page<>(page, size);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like("id",id);
        queryWrapper.orderByDesc("create_date");
        Page result = evaluateMapper.selectPage(itemPage, queryWrapper);
        PageDTO<Evaluate> pageDTO = new PageDTO<>();
        pageDTO.setTotal(result.getTotal());
        pageDTO.setList(result.getRecords());
        return ApiResult.success(pageDTO);
    }

    @Override
    public ApiResult updateEvaluate(EvaluateVO evaluateVO,Integer id) throws IOException, BusinessException {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.like("id",id);
        Evaluate evaluate = getOne(wrapper);
        return ApiResult.success(evaluateVO);
    }
}
